package com.upb.webserver.dao.mapper;

import com.upb.webserver.dao.entity.TbKeyword;
import com.upb.webserver.dao.entity.TbKeywordExample;
import java.util.List;
import java.util.Optional;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface TbKeywordMapper {

    @Select({ "select", "id, keyword, create_time, modify_time", "from tb_keyword", "where keyword = #{keyword,jdbcType=VARCHAR}" })
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "keyword", property = "keyword", jdbcType = JdbcType.VARCHAR), @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP) })
    TbKeyword selectByKeyword(String keyword);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_keyword
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbKeywordSqlProvider.class, method = "countByExample")
    long countByExample(TbKeywordExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_keyword
     *
     * @mbg.generated
     */
    @DeleteProvider(type = TbKeywordSqlProvider.class, method = "deleteByExample")
    int deleteByExample(TbKeywordExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_keyword
     *
     * @mbg.generated
     */
    @Delete({ "delete from tb_keyword", "where id = #{id,jdbcType=INTEGER}" })
    int deleteByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_keyword
     *
     * @mbg.generated
     */
    @Insert({ "insert into tb_keyword (keyword, create_time, ", "modify_time)", "values (#{keyword,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ", "#{modifyTime,jdbcType=TIMESTAMP})" })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = Integer.class)
    int insert(TbKeyword record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_keyword
     *
     * @mbg.generated
     */
    @InsertProvider(type = TbKeywordSqlProvider.class, method = "insertSelective")
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = Integer.class)
    int insertSelective(TbKeyword record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_keyword
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbKeywordSqlProvider.class, method = "selectByExample")
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "keyword", property = "keyword", jdbcType = JdbcType.VARCHAR), @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP) })
    List<TbKeyword> selectByExample(TbKeywordExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_keyword
     *
     * @mbg.generated
     */
    @Select({ "select", "id, keyword, create_time, modify_time", "from tb_keyword", "where id = #{id,jdbcType=INTEGER}" })
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "keyword", property = "keyword", jdbcType = JdbcType.VARCHAR), @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP) })
    TbKeyword selectByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_keyword
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbKeywordSqlProvider.class, method = "updateByExampleSelective")
    int updateByExampleSelective(@Param("record") TbKeyword record, @Param("example") TbKeywordExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_keyword
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbKeywordSqlProvider.class, method = "updateByExample")
    int updateByExample(@Param("record") TbKeyword record, @Param("example") TbKeywordExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_keyword
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbKeywordSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(TbKeyword record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_keyword
     *
     * @mbg.generated
     */
    @Update({ "update tb_keyword", "set keyword = #{keyword,jdbcType=VARCHAR},", "create_time = #{createTime,jdbcType=TIMESTAMP},", "modify_time = #{modifyTime,jdbcType=TIMESTAMP}", "where id = #{id,jdbcType=INTEGER}" })
    int updateByPrimaryKey(TbKeyword record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_keyword
     *
     * @mbg.generated
     */
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    @Insert({ "<script>", "insert into tb_keyword (keyword, ", "create_time, modify_time)", "values<foreach collection=\"list\" item=\"detail\" index=\"index\" separator=\",\">(#{detail.keyword,jdbcType=VARCHAR}, ", "#{detail.createTime,jdbcType=TIMESTAMP}, #{detail.modifyTime,jdbcType=TIMESTAMP})</foreach></script>" })
    int batchInsert(List<TbKeyword> list);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_keyword
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbKeywordSqlProvider.class, method = "getOneByExample")
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "keyword", property = "keyword", jdbcType = JdbcType.VARCHAR), @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP) })
    Optional<TbKeyword> getOneByExample(TbKeywordExample example);
}
